//
//  LGBloodPressureCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/3/6.
//

#import "LGCancerMonitorCell.h"

#define leftMargin   viewPix(58)
#define itemWidth    (Screen_W-viewPix(32)-leftMargin-viewPix(10)) //viewPix(90)

@interface LGCancerMonitorCell()
/**   */
@property (nonatomic , strong)UILabel *timeLabel;
/**   */
@property (nonatomic , strong)UIButton *contentBtn;

@end

@implementation LGCancerMonitorCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.baseView.backgroundColor = [UIColor colorWithString:@"#F5FBFF"];
        [self createSubView];
    }
    return  self;
}

-(void)setType:(LGPositionType)type{
    [super setType:type];
    CGFloat bottom = (type == LGPositionTypeBottom)?-viewPix(25):-viewPix(8);
    [self.timeLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView).offset(bottom);
    }];
}

-(void)setDataDic:(NSDictionary *)dataDic{
    [super setDataDic:dataDic];
    self.timeLabel.text = LGNSString(dataDic[@"record_time"]);
    if ([self.cellType isEqualToString:@"temperature"]) {
        //体温
        NSDictionary *iconDic = @{@"2":@"监测分数-偏高",@"1":@"监测分数-偏低"};
        [self.contentBtn setTitle:LGNSString(dataDic[@"t"]) forState:UIControlStateNormal];
        NSString *iconName = [dataDic[@"t_status"] integerValue]>0?@"":iconDic[LGNSString(dataDic[@"t_status"])];
//        [self.contentBtn setImage:[UIImage imageNamed:iconName] forState:UIControlStateNormal];
        
    }else if ([self.cellType isEqualToString:@"oxygen"]){
        //血氧
        NSDictionary *iconDic = @{@"2":@"监测分数-偏高",@"1":@"监测分数-偏低"};
        [self.contentBtn setTitle:LGNSString(dataDic[@"spo"]) forState:UIControlStateNormal];
        NSString *iconName = [dataDic[@"status"] integerValue]>0?@"":iconDic[LGNSString(dataDic[@"status"])];
//        [self.contentBtn setImage:[UIImage imageNamed:iconName] forState:UIControlStateNormal];
    }else{
        //体重
        NSDictionary *iconDic = @{@"偏高":@"监测分数-偏高",@"down":@"监测分数-偏低"};
        [self.contentBtn setTitle:LGNSString(dataDic[@"weight"]) forState:UIControlStateNormal];
        NSString *iconName = [dataDic[@"weightdiffstatus"] integerValue]>0?@"":iconDic[LGNSString(dataDic[@"weightdiffstatus"])];
//        [self.contentBtn setImage:[UIImage imageNamed:iconName] forState:UIControlStateNormal];
    }
//    [self.contentBtn setButtonInsetsStyle:LGButtonInsetsStyleRight marginSpace:3];
}


-(void)createSubView{
    [self.contentView addSubview:self.timeLabel];
    [self.contentView addSubview:self.contentBtn];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(viewPix(28));
        make.top.equalTo(self.contentView).offset(viewPix(8));
        make.bottom.equalTo(self.contentView).offset(-viewPix(8));
    }];
    [self.contentBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(leftMargin+viewPix(16));
        make.centerY.equalTo(self.timeLabel);
        make.width.equalTo(@(itemWidth));
        make.height.equalTo(@(viewPix(35)));
    }];
}

-(UILabel *)timeLabel{
    if(!_timeLabel){
        _timeLabel = [UILabel lableWithText:@"" colorString:@"#606266" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _timeLabel;
}

-(UIButton *)contentBtn{
    if(!_contentBtn){
        _contentBtn = [UIButton buttonWithTitle:@"" titleFont:LGFont(16) textColor:@"#282828" imageName:@""];
        _contentBtn.userInteractionEnabled = NO;
    }
    return _contentBtn;
}

@end
